#include "StdAfx.h"
#include "SaveMsgCon.h"
#include "Util/UtilInclude.h"
#include "CommandDef.h"
#include "WorkOut.h"


CSaveMsgBox::CSaveMsgBox(HWND hWnd)
	:CMessageBoxCon( hWnd )
{

}

CSaveMsgBox::~CSaveMsgBox(void)
{
}

BOOL CSaveMsgBox::InitControls(DWORD dwData)
{
	LANGUAGE_DECLARE;
	FONT_DECLARE;
	if(!m_config.Init(L"SaveMsgBox.xml"))
	{
		g_App.ShowMsgBox(CMD_MSGBOX_OK,L"",LAN_GETTEXT(Msg_ResError));
		return FALSE;
	}

	m_nAniType  = m_config.GetAniType();
	m_nExitAniType	= m_config.GetExitAniType();
	m_nAniSpeed = m_config.GetAniSpeed();
	BOOL bFromDll	= m_config.IsResFromDll();
	wstring str		= m_config.GetImage();	

	wstring strResPath = TEXT("Summary\\");
	HBITMAP hBitmap = CUtil::LoadBitmapEx( m_config.GetImage(),m_config.m_bFromDll);
	SetMaskBmp(hBitmap);

	//HBITMAP hBitmap = CUtil::LoadBitmapEx( strResPath+str,m_config.m_bFromDll);
	//SetBackGnd(hBitmap);
	SetRect( m_config.GetRect() );
	SetPainter(new CMsgBoxPainter());


	BtnParam btnInfo;
	TextParam txtInfo;
	BatTimePicParam  bat_time_pic;
	IBmpNumInfo      INumInfo;



	CBmpBtn*	pBtn = NULL;
	CText*		pTxt = NULL;


	BatTimePicParam picInfo;
	m_config.GetBatTimePicParam(picInfo,L"Pic_Bkgnd");
	CPicture *pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC, L"OK",picInfo.m_rc, CMD_MSGBOX_PIC));
	m_config.SetPicParam(pPic,picInfo);

	m_config.GetBatTimePicParam(picInfo,L"Pic_ICO");
	pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC, L"OK",picInfo.m_rc, CMD_SAVEMSG_ICO));
	m_config.SetPicParam(pPic,picInfo);

	m_config.GetBtnParam(btnInfo,L"Btn_Cancel");
	pBtn = (CBmpBtn*)this->AddControl(new CBmpBtn(SBS_RECT, LAN_GETTEXT(MSG_CANCEL),btnInfo.m_rc, CMD_SAVEMSG_BTN_CANCEL));
	m_config.SetBtnParam(pBtn,btnInfo);


	m_config.GetTextParam( txtInfo,TEXT("Txt_Title") );
	pTxt = (CText*)AddControl(new CText(SWS_STATIC, LAN_GETTEXT(txtInfo.m_strLangKey), txtInfo.m_rc, CMD_SAVEMSG_TXT_TITLE ));
	m_config.SetTextParam(pTxt,txtInfo);


	m_config.GetTextParam( txtInfo,TEXT("Txt_Save") );
	m_pTxtTip = (CText*)AddControl(new CText(SWS_STATIC, LAN_GETTEXT(txtInfo.m_strLangKey), txtInfo.m_rc, CMD_SAVEMSG_TXT_TIP ));
	m_config.SetTextParam(m_pTxtTip,txtInfo);

	m_config.GetTextParam( txtInfo,TEXT("Txt_Msg") );
	m_pTxtMsg = (CText*)AddControl(new CText(SWS_STATIC, LAN_GETTEXT(txtInfo.m_strLangKey), txtInfo.m_rc, CMD_SAVEMSG_TXT_MSG ));
	m_config.SetTextParam(m_pTxtMsg,txtInfo);

	ProgressParam proparam;
	m_config.GetProgreeParam( proparam,TEXT("Progress") );
	m_pPro = (CProgress*)AddControl(new CProgress(SWS_STATIC, L"", proparam.m_rc, CMD_SAVEMSG_PROGRESS ));
	m_config.SetProgressParam(m_pPro,proparam);
	m_pPro->SetRange( 0,100 );
	m_pPro->Show( FALSE );

	//SetStartSaving();
	return TRUE;
}

void CSaveMsgBox::OnCommand(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
	if ( CMD_SAMMARY_SAVE==wParam )
	{
	}
}

void  CSaveMsgBox::Paint(CDC *pDC)
{
	CMessageBoxCon::Paint( pDC );

}

void CSaveMsgBox::SetStartSaving()
{
	LANGUAGE_DECLARE;
	m_pPro->Show(TRUE);
	m_pPro->SetPos( 60 );
	m_pTxtMsg->SetCaption( LAN_GETTEXT(MSG_SAVING) );
	m_pTxtTip->Show( FALSE );
}
